package edu.bbu.bibliospring.backend.model;

import javax.persistence.*;


/**
 * Created by anna on 6/4/14.
 */

@Entity
@Table(name = "profile")
//@IdClass(BaseEntity.class)
public class Profile extends BaseEntity {

    private static final long serialVersionUID = 1L;

    @Column(name = "username")
    protected String username;
    @Column(name = "password")
    protected String password;
    @Column(name = "firstName")
    protected String firstName;
    @Column(name = "lastName")
    protected String lastName;

    /**
     * role:
     *  - librarian (unlimited access)
     *  - user (restricted access)
     */

    @Column(name = "role")
    protected String role;

    public Profile() {}

    public Profile(String username, String password, String firstName, String lastName, String role) {
        this.username = username;
        this.password = password;
        this.firstName = firstName;
        this.lastName = lastName;
        this.role = role;
    }

    //@OneToOne(mappedBy="message")
    public Profile getProfile() {
        Profile p = new Profile();
        p.setFirstName(this.firstName);
        p.setLastName(this.lastName);
        p.setUsername(this.username);
        p.setPassword(this.password);
        p.setRole(this.role);
        return p;
    }

    public void setProfile(Profile profile) {
        this.firstName = profile.getFirstName();
        this.lastName = profile.getLastName();
        this.username = profile.getUsername();
        this.password = profile.getPassword();
        this.role = profile.getRole();
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getFirstName() {
        return firstName;
    }

    public void setFirstName(String firstName) {
        this.firstName = firstName;
    }

    public String getLastName() {
        return lastName;
    }

    public void setLastName(String lastName) {
        this.lastName = lastName;
    }

    public String getRole() {
        return role;
    }

    public void setRole(String role) {
        this.role = role;
    }
}
